local skill = fk.CreateSkill{
  name = "tea__ranjiang"
}
---@type ActiveSkillSpec
local ranjiang = {
  name = "tea__ranjiang",
  anim_type = "offensive",
  prompt = "#tea__ranjiang-prompt",
  card_filter = function(self, player, to_select, selected)
    if #selected == 1 then return false end
    return table.contains(Self:getCardIds(Player.Equip), to_select)
  end,
  view_as = function(self, player, cards)
    if #cards ~= 1 then
      return nil
    end
    local c = Fk:cloneCard("fire__slash")
    c.skillName = skill.name
    c:addSubcard(cards[1])
    return c
  end,
  enabled_at_play = function(self, player)
    return player:getMark("@@tea__ranjiang_prohibit-turn") == 0
  end,
  enabled_at_response = function(self, player)
    return player:getMark("@@tea__ranjiang_prohibit-turn") == 0
  end,
}
---@type TargetModSpec
local ranjiang_targetmod = {
  bypass_distances = function(self, player, skill, card, to)
    return player:hasSkill(self) and (card or {}).skillName == "tea__ranjiang"
  end,
  bypass_times = function(self, player, skill, scope, card, to)
    return player:hasSkill(self) and (card or {}).skillName == "tea__ranjiang"
  end, 
  extra_target_func = function(self, player, skill, card)
    if player:hasSkill(self) and skill.trueName == "slash_skill" and card.name == "fire__slash" then
      return math.max(#player:getCardIds(Player.Equip) - 1, 0)
    end
  end,
}
---@type TrigSkelSpec<TrigFunc>
local ranjiang_delay = {
  can_refresh = function(self, event, target, player, data)
    if not (data.card or {}).skillNames then return end
    return player:hasSkill(self) and player == target and table.contains((data.card or {}).skillNames, "tea__ranjiang") and not data.damageDealt
  end,
  on_refresh = function(self, event, target, player, data)
    player.room:setPlayerMark(player, "@@tea__ranjiang_prohibit-turn", 1)
  end,
}
skill:addEffect("viewas", ranjiang)
skill:addEffect("targetmod", ranjiang_targetmod)
skill:addEffect(fk.CardUseFinished, ranjiang_delay)
return skill